package com.cyms.modules.base.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.cyms.common.utils.PageUtils;
import com.cyms.common.utils.Query;

import com.cyms.modules.base.dao.CompanyDao;
import com.cyms.modules.base.entity.CompanyEntity;
import com.cyms.modules.base.service.CompanyService;


@Service("companyService")
public class CompanyServiceImpl extends ServiceImpl<CompanyDao, CompanyEntity> implements CompanyService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
    	String code=(String) params.get("code");
    	String name=(String) params.get("name");
    	String personName=(String) params.get("personName");
    	String linkName=(String) params.get("linkName");
        Long createOrg = (Long) params.get("createOrg");
        Page<CompanyEntity> page = this.selectPage(
                new Query<CompanyEntity>(params).getPage(),
                new EntityWrapper<CompanyEntity>()
                        .eq(createOrg != null,"create_org",createOrg)
                        .orderBy("create_date", false)
                        .like(StringUtils.isNotBlank(code), "code", code)
                        .like(StringUtils.isNotBlank(name), "name", name)
                        .like(StringUtils.isNotBlank(personName), "person_name", personName)
                        .like(StringUtils.isNotBlank(linkName), "link_name", linkName)
        );

        return new PageUtils(page);
    }

}
